import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from "../views/Login";
import Home from "../views/Home";
import ArticlList from "../components/articlManage/ArticlList";
import ArticlRelese from "../components/articlManage/ArticlRelese";
import Column from "../components/columnManage/Column";
import Echars from "../components/dataEchars/Echars";
import User from "../components/userManage/User";
import ArticlDetailed from "../components/articlManage/ArticlDetailed";

Vue.use(VueRouter)

const routes = [//指定规则
  {
    path:'/',//路径
    name:'Login',
    component:Login,
    hidden:true//有了hidden,加载时候不进菜单
  },
  {
    path:'/home',//路径
    name:'Home',
    component:Home,
    hidden:true
  },
  {
    path:'/home',//路径
    name:'Home',
    component:Home,
    meta:{
      secMenu:true,//有二级菜单
        title:'文章管理',
        icon:'el-icon-document-copy',
        roles : ['ROLE_user','ROLE_admin']
    },
    children:[//子路由，这些组件想在home页切换
        {
      path:'/articlList',//路径
      name:'ArticlList',
      component:ArticlList,
      meta:{
        title: '文章列表'
      }

     },
      {
        path:'/articlRelese',//路径
        name:'ArticlRelese',
        component:ArticlRelese,
        meta:{
          title: '发表文章'
        }
      },
      {
        path:'/articlEdit',//路径
        name:'ArticlRelese',
        component:ArticlRelese,
        hidden:true,
        meta:{
          title: '编辑文章'
        }
      },
      ]
  },
  {
    path:'/home',//路径
    name:'Home',
    component:Home,
    meta:{
      secMenu:false//有无二级菜单
    },
    children: [
      {
        path:'/column',//路径
        name:'Column',
        component:Column,
        meta:{
          icon:'el-icon-menu',
          title: '栏目管理',
          roles : ['ROLE_user','ROLE_admin']
        }
      },
      {
        path:'/echars',//路径
        name:'Echars',
        component:Echars,
        meta:{
          icon:'el-icon-s-data',
          title: '统计数据',
          roles : ['ROLE_user','ROLE_admin']
        }
      },
      {
        path:'/user',//路径
        name:'User',
        component:User,
        meta:{
          icon:'el-icon-user',
          title: '用户管理',
          roles : ['ROLE_admin']
        }
      },
      {
        path:'/articlDetailed',//路径
        name:'ArticlDetailed',
        component:ArticlDetailed,
        hidden:true
      }
    ]
  },


]

const router = new VueRouter({
  routes
})

export default router
